# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=hypothesis
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=6.131.27
pkgrel=1
pkgdesc="Advanced Quickcheck style testing library for Python (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://hypothesis.works/'
msys2_repository_url='https://github.com/HypothesisWorks/hypothesis/tree/master/hypothesis-python/'
msys2_issue_tracker_url='https://github.com/HypothesisWorks/hypothesis/issues/'
msys2_documentation_url='https://hypothesis.readthedocs.io/'
msys2_changelog_url='https://hypothesis.readthedocs.io/en/latest/changes.html'
msys2_references=(
  'archlinux: python-hypothesis'
  'purl: pkg:pypi/hypothesis'
)
license=('spdx:MPL-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python-attrs"
         "${MINGW_PACKAGE_PREFIX}-python-sortedcontainers"
         "${MINGW_PACKAGE_PREFIX}-python-exceptiongroup")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-pytz: for datetime and django module"
            "${MINGW_PACKAGE_PREFIX}-python-faker: for fakefactory and django module"
            "${MINGW_PACKAGE_PREFIX}-python-django: for django module"
            "${MINGW_PACKAGE_PREFIX}-python-numpy: for numpy module"
            "${MINGW_PACKAGE_PREFIX}-python-pytest: for pytest module")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest")
options=('!strip')
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('9bd7e7e7bdbfc1b6e1f152dafacd398334588a374618490415209eeb26110b8d')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m pytest || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
